package com.janko.springbootbase.basic;

import java.sql.Ref;

/**
 * @Author nyk
 * @Date 2021/7/2 11:30
 * @Version 1.0
 * @Desc 反射引用实体结构
 */
public class ReflectDemo {

    /**
     * 获取反射的几种实现
     * @param args 变参
     */
    public static void main(String[] args) throws ClassNotFoundException {
        // 方式一(通过建立对象)
        ReflectDemo reflectDemo=new ReflectDemo();
        Class clazzObj1=reflectDemo.getClass();
        System.out.println("clazzObj1 = " + clazzObj1);

        // 方式二 相对路径加载--ClassLoader加载的形式
        Class clazzObj2 = Class.forName("com.janko.springbootbase.basic.ReflectDemo");
        System.out.println("clazzObj2 = " + clazzObj2);

        // 方式三 （通过类名） 获取三级缓存中的Bean对象
        Class  clazzObj3 = ReflectDemo.class;
        System.out.println("clazzObj3 = " + clazzObj3);

    }


    private int id;
    private String name;
    protected boolean sex;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isSex() {
        return sex;
    }

    public void setSex(boolean sex) {
        this.sex = sex;
    }
}

